package com.leetcode.algorithm.y22.m08.w3;

import com.leetcode.algorithm.common.TreeNode;

/**
 * 222. 完全二叉树的节点个数
 * 
 * https://leetcode.cn/problems/count-complete-tree-nodes/
 * 
 * @author jie.deng
 *
 */
class Question0222Solution01 {

	public int countNodes(TreeNode root) {
		if (root == null) {
			return 0;
		}
		int countLeft = countNodes(root.left);
		int countRight = countNodes(root.right);
		return countLeft + countRight + 1;
	}

}